#ifndef WIDGET_H
#define WIDGET_H

#include <QAxObject>
#include <QDateTime>
#include <QDir>
#include <QFile>
#include <QFileDialog>
#include <QList>
#include <QMessageBox>
#include <QSlider>
#include <QStandardPaths>
#include <QVariant>
#include <QVariantList>
#include <QWidget>
#include <QtDebug>

/*
  参考
    https://www.jianshu.com/p/051f1b718ba9
    https://cloud.tencent.com/developer/article/1431969
  快速读取:
    https://blog.csdn.net/u013541325/article/details/102511490
*/
typedef struct exlsData {
  exlsData(QString name, quint32 len) {
    company = name;
    maxLen = len;
  }
  QString company;
  quint32 maxLen;
  QVariantList lines;
} exlsData;

typedef struct {
  int row;
  int column;
} cRow_t;

QT_BEGIN_NAMESPACE
namespace Ui {
class Widget;
}
QT_END_NAMESPACE

class Widget : public QWidget {
  Q_OBJECT

public:
  Widget(QWidget *parent = nullptr);
  ~Widget();

private slots:
  void on_selectBtn_clicked();

  void on_procBtn_clicked();
  QString excelHCalc(int n); /* 计算列,Range名称 */
  // void writeExls();
  // QVariant readExlsAll();
  void writeExcel(QString fileName, QVariantList &list, quint32 maxLineLength);

  bool insterData(QList<exlsData *> &, QString name, QVariantList &);

  void on_selectBtn_2_clicked();
  cRow_t getHeadInfo(QVariantList &);

private:
  Ui::Widget *ui;
  QString exlsFile;
  QAxObject *excel;
  QAxObject *workbooks;
  QAxObject *workbook;
  QAxObject *worksheets;
  QAxObject *worksheet;
  QList<exlsData *> exlsLis;
  QVariantList *srcList;
  int srcHeadRow;
};
#endif // WIDGET_H
